<?php
/* @var $this UserController */
/* @var $model User */

$this->breadcrumbs=array(
	'Management'=>array('/site/management/'),
	'Maintenance'=>array('/site/maintenance/'),
	'Users',
);

$this->menu=array(
	//array('label'=>'List User', 'url'=>array('index')),
	array('label'=>'Create User', 'url'=>array('create', 'id'=>$model->iduser)),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#user-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Users</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<p><b>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
</b></p>

<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'user-grid',
	'dataProvider'=>(!(Yii::app()->user->restricted))? $model->search(): $model->search(Yii::app()->user->team_id),
	'filter'=>$model,
	'enableSorting' => false,
	'columns'=>array(
		/*array(
			'name'=>'iduser',
			'header'=>'Id',
			'value'=>'$data->iduser',
			'htmlOptions' => array(
								'style' => 'width:50px;text-align:center;',
							 ),
		),*/
		array(
			'name'=>'batch',
			'header'=>'Batch #',
			'value'=>'$data->batch',
			'htmlOptions' => array(
								'style' => 'width:50px;text-align:center;',
							 ),
		),
		array(
			'name'=>'username',
			'header'=>'Username',
			'value'=>'$data->username',
			'htmlOptions' => array(
								'style' => 'width:50px;text-align:center;',
							 ),
		),
		array(
			'name'=>'fullname',
			'header'=>'Full Name',
			'value'=>'$data->fullname',
			'htmlOptions' => array(
								'style' => 'text-align:center;',
							 ),
		),
		//'password',
		array(
			'name'=>'email',
			'header'=>'Email',
			'value'=>'$data->email',
			'htmlOptions' => array(
								'style' => 'width:70px;text-align:center;',
							 ),
		),
		array(
			'name'=>'enabled',
			'header'=>'Enabled',
			'value'=> 'User::getYesNoValue($data->enabled)',
			'filter' => array('0'=>'No', '1'=>'Yes'),
			'htmlOptions' => array(
								'style' => 'width:20px;text-align:center;',
							 ),
		),
		array(
			'name'=>'idrole',
			'header'=>'Role',
			'value'=>'$data->role_relation->name;',
			'filter'=> CHtml::listData(Role::model()->findAll(array('order'=>'name ASC','condition'=>'team_id= '.Yii::app()->user->team_id)),
																		 'idrole',
																		 'name'
																		 ),
			'htmlOptions' => array(
								'style' => 'width:120px;text-align:center;',
							 ),			
		),			
		/*
		'restricted',
		*/
		array(
			'class'=>'CButtonColumn',
			'header'=>'Actions',
			'template'=>'{view}{update}',
			'buttons'=>array(
						'view'=>array(
									'url'=>'Yii::app()->createUrl("user/view", array("id"=>$data->iduser))',
									'label'=>'View',
									'options' => array('style'=>'width:10px;','title'=>'View Details')
						          ),
						'update'=>array(
									'url'=>'Yii::app()->createUrl("user/update", array("id"=>$data->iduser))',
									'label'=>'Update',
									//'visible'=> '(($data->idteam == Yii::app()->user->team_id) or (Yii::app()->user->can_create_edit_roles))',
									'options' => array('style'=>'width:10px;','title'=>'Update')
						          ),
						
					   ),			
		),	
	),
)); ?>
